package com.devunion.salon.persistence;

import javax.persistence.*;
import java.sql.Date;

/**
 *
 CREATE TABLE `giftcard` (
   `id` int(11) NOT NULL auto_increment,
   `code` char(10) NOT NULL,
   `created` datetime NOT NULL default '0000-00-00 00:00:00',
   `amount` decimal(10,3) NOT NULL default '0.000',
   `payment` varchar(20) default NULL,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `code` (`code`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
 *
 * @author Viktar Liaskovich
 */

@Entity
@Table(name = "gift_card")
public class GiftCard extends BasePersistentObject {

    @Column(name = "code", length = 10, nullable = false)
    private String code;

    @Column(name = "created", nullable = false)
    private Date created;

    @Column(name = "amount", nullable = false)
    private Float amount;

    @ManyToOne()
    private Location location;

    @OneToOne(mappedBy = "giftCard", optional = false)
    private Transaction transaction;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Float getAmount() {
        return amount;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Transaction getTransaction() {
        return transaction;
    }

    public void setTransaction(Transaction transaction) {
        this.transaction = transaction;
    }
}
